#include <stdio.h>

int main()
{
    int n, count = 0;

    printf("请输入一个正整数 n：");
    scanf("%d", &n);

    printf("%d以内的全部素数为：", n);
    for (int num = 2; num <= n; num++)
    {
        int isPrime = 1;

        for (int i = 2; i * i <= num; i++)
        {
            if (num % i == 0)
            {
                isPrime = 0;
                break;
            }
        }

        if (isPrime)
        {
            printf("%d ", num);
            count++;
        }
    }

    printf("\n%d以内的素数个数为：%d\n", n, count);

    return 0;
}